package com.atguigu.juc.locks;

import java.util.concurrent.TimeUnit;

//两个静态同步方法（锁的是对象模版）
class Phone5{
    public static synchronized void sengEmail(){
        try {
            TimeUnit.SECONDS.sleep(2);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName() + "正在发邮件...");
    }
    public static synchronized void sengSMS(){
        System.out.println(Thread.currentThread().getName() + "正在发短信...");
    }
}

public class Lock8_5 {
    public static void main(String[] args) {
        Phone5 phone5 = new Phone5();

        new Thread(()->{phone5.sengEmail();},"t1").start();

        try {
            TimeUnit.MILLISECONDS.sleep(10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        new Thread(()->{phone5.sengSMS();},"t2").start();
    }
}
